//
//  ViewController.m
//  10--CustomTableViewCell
//
//  Created by 冀永金 on 16/7/27.
//  Copyright © 2016年 冀永金. All rights reserved.
//

#import "ViewController.h"
#import "CustomTableViewCell.h"
#import "NewsObject.h"
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) NSMutableArray *nameArray;
@property (nonatomic, strong) UITableView *tableView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // 数据的传递物依赖modle ，传对象  存对象  取对象
    NewsObject *newsObject = [[NewsObject alloc]initWithNewsImage:@"123_10" newsTitle:@"aa" newsDescription:@"bb" newsNumberCount:@"cc"];
    self.nameArray = [NSMutableArray arrayWithObjects:newsObject,newsObject,newsObject,newsObject,newsObject, nil];
//    NSArray *arr = @[@"唐益梦", @"张合尉", @"高雅馨", @"符淋淋", @"孙遥", @"李毅然", @"于瀚", @"沙长健", @"卢思彤", @"徐昊", @"曹冠雄", @"陈丹明", @"罗浩", @"肖扬", @"王道林", @"宫雪", @"李成", @"冀永金", @"姜浩", @"罗鹏飞", @"李昊林", @"郭宝", @"马峰", @"刘坦奇", @"殷明静", @"邓凯", @"徐康", @"王鍠", @"韩旭", @"杨睿", @"张信宝", @"姜程程", @"包铭礼", @"杜江", @"苗钧豪"];
//    self.nameArray = [NSMutableArray arrayWithArray:arr];
   self.tableView =[[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    [self.view addSubview:_tableView];
    _tableView.delegate = self;
    _tableView.dataSource =self;
    [_tableView registerClass:[CustomTableViewCell class] forCellReuseIdentifier:@"pool"];
    
    self.navigationItem.rightBarButtonItem = self.editButtonItem;
    // Do any additional setup after loading the view, typically from a nib.
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
    [super setEditing:editing animated:animated];
    [_tableView setEditing:editing animated:animated];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.nameArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CustomTableViewCell*cell = [tableView dequeueReusableCellWithIdentifier:@"pool" forIndexPath:indexPath];
    NewsObject *newsObject = self.nameArray[indexPath.row];

    [cell setObject:newsObject];
   // cell.textLabel.text = self.nameArray[indexPath.row];
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 100;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
